﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MESMian.EntityMapping
{
    public class MaterialReceiveDetailsMapping : IEntityTypeConfiguration<MaterialReceiveDetails>
    {
        public void Configure(EntityTypeBuilder<MaterialReceiveDetails> builder)
        {
            builder.ToTable("MaterialReceiveDetails");
            builder.HasKey(p => p.MaterialReceiveDetailId);
            builder.Property(p => p.MaterialReceiveDetailId)
                .HasComment("产品生产领料明细主键，自动编号");

            builder.Property(p => p.MaterialReceiveId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("产品生产领料主键，外键（MaterialReceives）");

            builder.Property(p => p.ProductionPlanDetailId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("生产计划明细主键，外键（ProductionPlanDetails）");

            builder.Property(p => p.StoreId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("领料仓库，外键（Stores）");

            builder.Property(p => p.ReceiveCount)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("预计需要物料的数量");

            builder.Property(p => p.Status)
                .IsRequired()
                .HasColumnType("int")
                .HasDefaultValue(0)
                .HasComment("数据状态（0正常，1删除），默认值0");

            builder.Property(p => p.CreateUserId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("创建人，外键（Users）");

            builder.Property(p => p.CreateTime)
                .IsRequired()
                .HasColumnType("datetime")
                .HasDefaultValueSql("GETDATE()")
                .HasComment("创建时间，默认值为当前时间");

            builder.Property(p => p.LastUpdateUserId)
                .HasColumnType("int")
                .HasComment("最后一次修改人，外键（Users）");

            builder.Property(p => p.LastUpdateTime)
                .HasColumnType("datetime")
                .HasComment("最后一次修改时间");
        }
    }

}
